package com.antdesignbackend.backend.service.impl;

import com.antdesignbackend.backend.entity.Log;
import com.antdesignbackend.backend.entity.entityVo.LogVo;
import com.antdesignbackend.backend.mapper.LogMapper;
import com.antdesignbackend.backend.service.ILogService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.ibatis.javassist.bytecode.stackmap.BasicBlock;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class LogServiceImpl extends ServiceImpl<LogMapper, Log> implements ILogService {
    @Autowired
    private LogMapper logMapper;
    @Override
    public void updateData(UpdateWrapper<Log> ew) {
        logMapper.updateData(ew);
    }

    @Override
    public void insertData(Log model) {
        logMapper.insertData(model);
    }

    @Override
    public void deleteById(int id) {
        logMapper.deleteById(id);
    }

    @Override
    public List<LogVo> filter(QueryWrapper<LogVo> queryWrapper) {
        return logMapper.filter(queryWrapper);
    }

    @Override
    public List<LogVo> search(QueryWrapper<LogVo> queryWrapper, Page<LogVo> page) {
        return logMapper.search(queryWrapper, page);
    }
    @Override
    public Integer count(QueryWrapper<LogVo> queryWrapper) {
        return logMapper.count(queryWrapper);
    }
    @Override
    public void WriteLog(int logType,String logContent,String operationUser) {
       try
       {
           Log model=new Log();
           model.setCreateTime(new Date());
           model.setLogContent(logContent);
           model.setLogType(logType);
           model.setUserName(operationUser);
           logMapper.insert(model);
       }
        catch (Exception ex)
        {
            int k=0;
        }
    }

}
